<template>
	<el-dialog 
		:visible.sync="checkShow"
		:append-to-body='true'
		@close="closeSelf" width="55%" 
		height="40%"
		:show-close='false'
		class="subOpinionDialog"
		:closeOnClickModal='false'
		>
		<span slot="title" class="dialog-title">
			
		  	检测单{{subModel == 'myCheck' ?'校核':'审核'}}
			<el-button  size="mini" @click="closeSelf" class="popupClose">关闭</el-button>
		</span>
		<el-row style = "margin-bottom:20px;">
			<span>是否通过：</span>
			 <el-select v-model="isPass" placeholder="请选择" size="mini">
			    
			    <el-option label="同意" :value="true"></el-option>
			    <el-option label="驳回" :value="false"></el-option>
			  </el-select>
		</el-row>
		<el-row v-if="!isPass">
			<div style="padding:10px 0;" class = "inlineblock">驳回意见：</div>
			<el-input
			  type="textarea"
			  :rows="2"
			  size="mini"
			  placeholder="请输入内容"
			  v-model="opinion" class = "inlineblock" style = "width:calc(100% - 80px)">
			</el-input>
		</el-row>
		  <span slot="footer" class="dialog-footer">
		    <el-button @click="closeSelf" size="mini">取 消</el-button>
		    <el-button type="primary" @click="submitClick" size="mini" :disabled = "!isRepeat">确 定</el-button>
		  </span>
	</el-dialog>
</template>

<script>
	export default{
		props:['checkShow','subModel','subTestpanelData'],
		data(){
			return {
				isPass:true,
				opinion:'',
				isRepeat:true,
				receptModuleId:null,
			}
		},
		watch: {
			checkShow(val, oldVal) {
				if (val) {
					
					if (this.subModel == 'myCheck') {
						this.receptModuleId = this.util.getModuleId({ module: "mygroupsanjishenhe" })
						console.log(this.subModel,this.receptModuleId )
					}

				}
			},
		},
		
		methods:{
			submitClick(){
				let msg;
				var url = "";
				if(this.isPass){
					if(this.subModel == "myCheck"){
						msg = '校核成功！'
					}else{
						msg = '审核成功！'
					}
				}else{
					msg = '驳回成功！'
				}
				if(this.subModel == "myCheck"){
					url = "/detection/checkSubBatch.htm";
					this.subTestpanelData.moduleId = this.receptModuleId;
					this.subTestpanelData.operation = 'check';
				}else{
					url = "/detection/reviewSubBatch.htm"
				}
				this.subTestpanelData.isPass = this.isPass;
				this.subTestpanelData.opinion = this.opinion;
				this.isRepeat = false
 				this.$http({
			          method: 'post', 
			          apiUrl: url,
			          params:this.subTestpanelData,
			          isJson:true,
			       }).then(res=>{
			          if(res.code === 0){
						this.isRepeat = true
						this.$notify({
							title:"成功",
							message:msg,
							type:"success"
						})
						if(this.isPass){
							this.updateTaskBySubTestItem()
						}
						this.$store.dispatch('getWorkflowList',0).then(res=>{
							// this.$notify({
							// 	showClose: true,
							// 	message: '操作成功',
							// 	type: 'success',
							// 	title:"成功"
							// })
						})
						this.closeSelf();
						this.$parent.close();
						this.$parent.$parent.getTestBatchs(this.$parent.$parent.testItemQuery)

			          } 
			        },)
			      
			},
			updateTaskBySubTestItem(){
				this.$http({
					method: 'post', 
					apiUrl: '/detection/updateTaskBySubTestItem.htm',
					params:this.subTestpanelData,
					isJson:true,
				}).then(res=>{
					if(res.code === 0){
						
					} 
				},)
			},
			closeSelf(){
				this.$emit('update:checkShow', false);
				this.isPass = true;

			}
		},
		computed:{
			
		}
	}
</script>

<style>
	.subOpinionDialog .el-dialog {
		height: 50%;
	}
	.subOpinionDialog .el-dialog .el-dialog__body{
		padding:18px;
	}
</style>